package com.wty.cmims.controller;

import com.wty.cmims.pojo.HealthRecord;
import com.wty.cmims.pojo.ResponseResult;
import com.wty.cmims.service.HealthRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/healthRecord")
@Tag(name = "健康信息", description = "社区医疗信息管理系统api接口")
public class HealthRecordController {
    @Autowired
    private HealthRecordService healthRecordService;

    //居民健康信息获取
    @PostMapping("/find")
    @Operation(summary = "健康信息获取", description = "健康信息获取")
    @Parameter(name = "userId",description = "居民ID")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<HealthRecord> healthRecordFind(@RequestParam(name = "user_id") Integer userId){
        return healthRecordService.healthRecordFind(userId);
    }

    // 居民健康信息更新
    @PutMapping("/update")
    @Operation(summary = "健康信息修改", description = "健康信息修改")
    @Parameter(name = "healthRecord",description = "健康信息")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<HealthRecord> healthRecordUpdate(@RequestBody HealthRecord healthRecord){
        return healthRecordService.healthRecordUpdate(healthRecord);
    }
}